package Thread;

public class MThread {
    public static void main(String[] args) {
        M mThread = new M();
        Thread t1 = new Thread(mThread);
        t1.setName("窗口一");
        t1.start();
        Thread t2 = new Thread(mThread);
        t2.setName("窗口二");
        t2.start();

    }
}
class M implements Runnable{
    private int  tickets=100;//此方法中不需要加static，因为只创建了一个M类的对象
    @Override
    public void run() {
    while (true){
        if (tickets>0){
            System.out.println(Thread.currentThread().getName()+"买票，票号："+tickets);
            tickets--;
             }

        }
    }
}